package controller;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Vector;

import query.KundeSuchenQuery;
import query.TarifSuchenQuery;
import query.TarifeSuchenQuery;
import model.Kunde;
import model.Tarif;

public class ControllerTarif implements java.io.Serializable {
	private static final long serialVersionUID = 2661011647794721161L;
	
	static public Vector<Tarif> getData(){
		try{
			//Socket erstellen
			Socket socket = new Socket("20.49.184.100", 5550);
			
			//Outputstream erstellen
			ObjectOutputStream clientOutputStream = new ObjectOutputStream(
					socket.getOutputStream());
			
			//Inputstream erstellen
			ObjectInputStream clientInputStream = new ObjectInputStream(
					socket.getInputStream());
			
			//Controller KundeSuchenQuery erstellen
			TarifeSuchenQuery ks = new TarifeSuchenQuery();
			
			//Controller Objekt an Server senden
			clientOutputStream.writeObject(ks);
	
			//Antwort von Server erhalten
			Object inputObj = clientInputStream.readObject();
			Vector<Tarif> vector = (Vector<Tarif>) inputObj;
			return vector;
		} catch (Exception e){
			
		}
		
		return null;
		
		
		
	}
	
	
	static public Tarif getData(int id){
		try{
			//Socket erstellen
			Socket socket = new Socket("20.49.184.100", 5550);
			
			//Outputstream erstellen
			ObjectOutputStream clientOutputStream = new ObjectOutputStream(
					socket.getOutputStream());
			
			//Inputstream erstellen
			ObjectInputStream clientInputStream = new ObjectInputStream(
					socket.getInputStream());
			
			//Controller KundeSuchenQuery erstellen
			TarifSuchenQuery ks = new TarifSuchenQuery();
			ks.setId(id);
			
			//Controller Objekt an Server senden
			clientOutputStream.writeObject(ks);
	
			//Antwort von Server erhalten
			Object inputObj = clientInputStream.readObject();
			Tarif tarif = (Tarif) inputObj;
			return tarif;
		} catch (Exception e){
			
		}
		
		return null;	
		
	}
	
	
	

}
